package base

import "github.com/gogf/gf/v2/frame/g"

type CommonResult struct {
	Code int         `json:"code" dc:"状态码"`
	Data interface{} `json:"data" dc:"返回数据"`
	Msg  string      `json:"msg" dc:"消息描述"`
}
type PageParam struct {
	PageNum       *int     `json:"pageNum" dc:"页码"`
	PageSize      *int     `json:"pageSize" dc:"每页条数"`
	OrderBy       string   `json:"orderBy" dc:"排序字段"`
	Keywords      string   `json:"keywords" dc:"关键字"`
	SearchKeys    string   `json:"searchKeys" dc:"搜索字段"`
	LabelKey      string   `json:"labelKey" dc:"通用下拉·label字段名"`
	ValueKey      string   `json:"valueKey" dc:"通用下拉·value字段名"`
	ExtFieldNames string   `json:"extFieldNames" dc:"通用下拉·扩展字段名"`
	IncludeType   *int     `json:"includeType" dc:"通用下拉·包含类型: 0-默认, 1-包含指定ID并置顶, 2-仅包含指定ID"`
	IncludeIds    []string `json:"includeIds" dc:"通用下拉·包含的ID列表"`
	QueryParamMap g.Map    `json:"-"` // 忽略 Swagger 文档和 JSON 绑定
}
type PageVO struct {
	PageNum     int           `json:"pageNum" dc:"页码"`
	PageSize    int           `json:"pageSize" dc:"每页条数"`
	RecordCount int           `json:"recordCount" dc:"记录总数"`
	TotalPage   int           `json:"totalPage" dc:"总页数"`
	Rows        []interface{} `json:"rows" dc:"数据列表"`
}
type LabelValueVO struct {
	Ext   g.Map       `json:"ext" dc:"扩展字段"`
	Label string      `json:"label" dc:"标签"`
	Value interface{} `json:"value" dc:"值"`
}
type DictItemModelVO struct {
	Name          string      `json:"name" dc:"字典项名称"`
	DictItemValue interface{} `json:"dictItemValue" dc:"字典项值"`
	DictItemKey   string      `json:"dictItemKey" dc:"字典项键"`
}
type DictModelVO struct {
	Name    string            `json:"name" dc:"字典名称"`
	DictKey string            `json:"dictKey" dc:"字典唯一编码"`
	Items   []DictItemModelVO `json:"items" dc:"字典项"`
}

// Ok 返回成功-无数据
func Ok() *CommonResult {
	return &CommonResult{
		Code: 0,
		Msg:  "成功",
		Data: nil,
	}
}

// Fail 返回失败-自定义状态码和消息
func Fail(code int, msg string) *CommonResult {
	return &CommonResult{
		Code: code,
		Msg:  msg,
		Data: nil,
	}
}

// FailWithDefaultCode 返回失败-默认状态码和自定义消息
func FailWithDefaultCode(msg string) *CommonResult {
	return Fail(99999999, msg)
}

// Data 返回成功-带数据
func Data(data interface{}) *CommonResult {
	return &CommonResult{
		Code: 0,
		Msg:  "成功",
		Data: data,
	}
}
